using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DTO;

namespace DAO
{
   public static class AdminDAO
   {
       #region Huỳnh Tấn Công
     
       public static bool ThemAdmin(AdminDTO AdminDTO)
       {
           OleDbConnection con = Dataprovider.ketnoicsdl();
           string sql = "INSERT INTO Admin(TenDN, MatKhau, TrangThai) values('" + AdminDTO.TenDN + "','" + AdminDTO.MatKhau + "', 'Hoạt Động' )";
           return Dataprovider.chaycaulenh(sql, con);
       }

       public static DataTable DanhSachAdmin()
       {
           OleDbConnection con = Dataprovider.ketnoicsdl();
           string sql = "select * from Admin";
           return Dataprovider.laythongtinbang(sql, con);
       }

       public static bool XoaAdmin(AdminDTO AdminDTO)
       {
           OleDbConnection con = Dataprovider.ketnoicsdl();
           string sql = "UPDATE Admin SET TrangThai='Không Hoạt Động' where TenDN='" + AdminDTO.TenDN + "'";
           return Dataprovider.chaycaulenh(sql, con);
       }

       public static bool CapNhatAdmin(AdminDTO AdminDTO)
       {
           OleDbConnection con = Dataprovider.ketnoicsdl();
           string sql = "UPDATE Admin SET MatKhau='" + AdminDTO.MatKhau + "', TrangThai='" + AdminDTO.TrangThai + "'  where TenDN='" + AdminDTO.TenDN + "'";
           return Dataprovider.chaycaulenh(sql, con);
        }

      
        #endregion
    }
}
